package com.xcity.pomelo.response;

import java.util.ArrayList;
import java.util.List;

import com.xcity.db.entity.Player;
import com.xcity.game.activity.newplayer.ActivityNewPlayerService;
import com.xcity.game.activity.newplayer.NewPlayerTask;
import com.xcity.pomelo.response.ActivityNewPlayerInfoResponse.HalfShopItem;

import naga.x.game.time.TimeUpdater;
import naga.x.net.impl.pomelo.PomeloMessage;
import naga.x.net.impl.pomelo.protocol.Message;

@PomeloMessage(type = Message.Type.RESPONSE)
public class ActivityNewPlayerHalfShopListResponse extends Response {

	public List<HalfShopItem> halfShopList;
	public ActivityNewPlayerHalfShopListResponse(int serial, Player player, int day) {
		super(serial);
		int today = TimeUpdater.getInstance().today();
		halfShopList = new ArrayList<HalfShopItem>();
//		int currentDay = today - player.getNewPlayerTasks().getCreatDay() + 1;
//		for(int i = 1; i <= ActivityNewPlayerService.COUNT_DAY; i++){
//			if(currentDay >= i){
//				List<NewPlayerTask> taskList = player.getNewPlayerTasks().getTaskListByDay(i);
//				for(int j = 0; j < taskList.size(); j++){
//					NewPlayerTask task = taskList.get(j);
//					byte type = task.getTypeId();
//					if(task.getTemplate().getBan() != 1){
//						if(type == ActivityNewPlayerService.FUNC_TYPE_HALF_SHOP && currentDay == i){
//							HalfShopItem halfShopItem = new HalfShopItem(task);
//							halfShopList.add(halfShopItem);
//						}
//					}
//				}
//			}
//		}
		List<NewPlayerTask> taskList = player.getNewPlayerTasks().getTaskListByDay(day);
		for(int j = 0; j < taskList.size(); j++){
			NewPlayerTask task = taskList.get(j);
			byte type = task.getTemplate().getType();
			if(task.getTemplate().getBan() != 1){
				if(type == ActivityNewPlayerService.FUNC_TYPE_HALF_SHOP){
					HalfShopItem halfShopItem = new HalfShopItem(task);
					halfShopList.add(halfShopItem);
				}
			}
		}
	}

}
